package com.qf.microuser.user.controller;

import com.qf.common.core.annopation.NoLoginCheck;
import com.qf.common.core.common.R;
import com.qf.microuser.user.param.LoginParam;
import com.qf.microuser.user.service.UserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * --- 缘分让我们相遇乱世以外 ---
 *
 * @author SJY
 * 2024/12/26
 */
@RestController
@RequestMapping("/user")
@Validated
public class LoginController {
    @Resource
    private UserService userService;
    /**
     * 用户登录
     * 如果使用的类对象中使用了验证注解,控制层参数就需要使用@Valid注解进行验证
     */
    @NoLoginCheck
    @PostMapping("/login")
    public R login(@RequestBody @Valid LoginParam loginParam) {
        Object token = userService.login(loginParam);
        return R.ok(token);
    }
}
